<?php

use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $searchModel yak\layui\search\AuthItemSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '角色列表';
$this->params['breadcrumbs'][] = $this->title;

$this->params['link'] = '/sys/rbac/roles';
?>

<div id="menu-index">

    <script type="text/html" id="toolBar">
        <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="create">
            <i class="layui-icon layui-icon-node"> 创建角色</i>
        </a>
        <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch">
            <i class="layui-icon layui-icon-delete"> 批量删除角色</i>
        </a>
        <a class="layui-btn layui-btn-info layui-btn-sm" href="<?= Url::toRoute('permissions') ?>">
            <i class="layui-icon layui-icon-user"> 权限节点</i>
        </a>
    </script>

    <script type="text/html" id="tool">
        <a class="layui-btn layui-btn-warm layui-btn-xs" href="<?= Url::toRoute(['auth']) ?>?name={{d.name}}">权限</a>
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>

    <div class="layui-card">
        <div class="layui-card-header yak-search-card-header">
            <?= $this->render('_search', ['model' => $searchModel]) ?>
        </div>
        <div class="layui-card-body">
            <table id="role-table" lay-filter="role-table-filter"></table>
        </div>
    </div>

    <?= \yak\layui\widgets\grid\LayuiGridView::widget([
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
        'tableId' => 'role-table',
        'tableFilter' => 'role-table-filter',
        'searchFilter' => 'role-search',
        'tableOptions' => [
            'url' => Url::toRoute(['roles']),
            'defaultCondition' => ['type' => $searchModel->type],
            'toolbar' => '#toolBar',
        ],
        'eventOptions' => [
            'detail' => [
                'url' => Url::toRoute(['role-view']),
                'condition' => ['name' => ':name'],
            ],
            'edit' => [
                'url' => Url::toRoute(['role-update']),
                'label' => '更新权限节点',
                'condition' => ['name' => ':name'],
                'openRefresh' => true
            ],
            'del' => [
                'url' => Url::toRoute(['role-delete']),
                'message' => '确定删除该项目？',
                'condition' => ['name' => ':name']
            ],
            'create' => [
                'url' => Url::toRoute(['role-create']),
                'label' => '创建权限节点',
                'openRefresh' => true
            ],
            'deleteBatch' => [
                'url' => Url::toRoute(['role-batch-delete']),
                'message' => '确定删除？',
                'condition' => ['names' => 'name']
            ]
        ]
    ]) ?>

</div>


